﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CrawlerApp.Views.Shared
{
    /// <summary>
    /// Header.xaml 的交互逻辑
    /// </summary>
    public partial class Header : UserControl
    {

        #region private
        Window parentWindow;
        #endregion

        #region public
        [DefaultValue("标题内容"), Description("标题")]
        public string Title
        {
            get { return title.Text; }
            set { title.Text = value; }
        }
        [DefaultValue(true), Description("是否显示最大化/还原按钮")]
        public Visibility MaximizeBox
        {
            get { return max.Visibility = Visibility; }
            set { max.Visibility = value; }
        }
        [DefaultValue(true), Description("是否显示最大化按钮")]
        public Visibility MinimizeBox
        {
            get { return min.Visibility; }
            set { min.Visibility = value; }
        }
        [DefaultValue(true), Description("圆角设置")]
        public CornerRadius CornerRadius 
        {
            get
            {
                return bd.CornerRadius;
            }
            set
            {
                bd.CornerRadius = value;
            }
        }
        #endregion

        public Header()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            parentWindow = Window.GetWindow(Parent);
        }

        private void TitleClick(object sender, MouseButtonEventArgs e)
        {
            if(e.ClickCount == 2)
            {
                parentWindow.WindowState = parentWindow.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
            }
        }

        private void ExitClick(object sender, RoutedEventArgs e)
        {
            parentWindow.Close();
        }

        private void MaxClick(object sender, RoutedEventArgs e)
        {
            parentWindow.WindowState = parentWindow.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
        }

        private void MinClick(object sender, RoutedEventArgs e)
        {
            parentWindow.WindowState = WindowState.Minimized;
        }
    }
}
